package com.xx.job;


import org.hyperic.sigar.CpuPerc;
import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarException;
import org.hyperic.sigar.CpuInfo;

public class Test {
    public static void main(String[] args) throws SigarException {
        Sigar sigar = new Sigar();
        //CPU的总量（单位：HZ）及CPU的相关信息
       CpuInfo[] infos = sigar.getCpuInfoList();
        CpuPerc cpuList[] = null;
        System.out.println("共块cpu"+infos.length);
        cpuList = sigar.getCpuPercList();
        for (int i = 0; i < infos.length; i++) {// 不管是单块CPU还是多CPU都适用
            CpuInfo info = infos[i];
            System.out.println("第" + (i + 1) + "块CPU信息");
            System.out.println("CPU的总量MHz:    " + info.getMhz());// CPU的总量MHz
            System.out.println("CPU生产商:    " + info.getVendor());// 获得CPU的卖主，如：Intel
            System.out.println("CPU类别:    " + info.getModel());// 获得CPU的类别，如：Celeron
            System.out.println("CPU缓存数量:    " + info.getCacheSize());// 缓冲存储器数量
            //当前CPU的用户使用率、系统使用率、当前等待率、当前空闲率、总的使用率
        }
    }

}
